package STUDENT.NGUYENHUUTHANG.STRUCTURE_PROGRAMMING.EXAMPLES;

import java.util.Scanner;

public class tinhtoan {

	public static void main(String[] args) {
		System.out.println("Nhap vao so a = ");
		Scanner sc = new Scanner(System.in);
		String tg = sc.nextLine();
		if (tg.isEmpty()) {
			System.out.println("Ban chua nhap so a!");

		} else
			System.out.println("Nhap vao so b = ");
		String tg1 = sc.nextLine();
		if (tg1.isEmpty()) {
			System.out.println("Ban chua nhap so b!");
		} else
			System.out.println("Chon phep toan: ");
		String pheptoan = sc.nextLine();
		if (pheptoan.isEmpty() || (pheptoan.equals("cong") == false && pheptoan.equals("tru") == false
				&& pheptoan.equals("nhan") == false && pheptoan.equals("chia") == false)) {
			System.out.println("Ban chua chon phep toan hoac chon sai phep toan!");
		} else if (pheptoan.equals("cong")) {
			double a = Double.parseDouble(tg);
			double b = Double.parseDouble(tg1);
			double kq = a + b;
			System.out.println("Ket qua: " + kq);
		}
		if (pheptoan.equals("tru")) {
			double a = Double.parseDouble(tg);
			double b = Double.parseDouble(tg1);
			double kq = a - b;
			System.out.println("Ket qua: " + kq);
		}
		if (pheptoan.equals("nhan")){
			double a = Double.parseDouble(tg);
			double b = Double.parseDouble(tg1);
			double kq = a * b;
			System.out.println("Ket qua: " + kq);
		}
		if (pheptoan.equals("chia")){
			double a = Double.parseDouble(tg);
			double b = Double.parseDouble(tg1);
			double kq = a / b;
			System.out.println("Ket qua: " + kq);
		}
	}

}
